//
//  meListCell.swift
//  LeDian
//
//  Created by 三秒文化 on 16/3/17.
//  Copyright © 2016年 51ledian. All rights reserved.
//

import UIKit

class meListCell: UITableViewCell {
    
    let margin = 15
    var listPicImg:UIImageView?
    var listName:UILabel?
    var rightPic:UIImageView?
    var rightDesc:UILabel?
    
    var model:meListCellModel?{
        
        didSet {
            
            listPicImg?.image = UIImage.init(named: (model?.listPicName)!)
            listName?.text = model?.listName
            rightDesc?.text = model?.rightDesc
            
            if listName?.text == "钱包" {
                
             rightDesc?.textColor = LDFontColor.Red
            }else{
                
            rightDesc?.textColor = LDFontColor.LightGray
            }
        }
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .None
        setupContentView()
        setupFrame()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupContentView() {
        
//        listPicImg = UIImageView.setImageView(25/2)
        listPicImg = UIImageView()
        listName = UILabel.setDetailsLab("钱包", fontSize: 14, titleColor: LDFontColor.Black,Alignment: nil)

        rightDesc = UILabel.setDetailsLab("..", fontSize: 14, titleColor: LDFontColor.LightGray,Alignment: NSTextAlignment.Right)
        
        rightPic = UIImageView.init(image: UIImage.init(named: "箭头.png"))
        
        addSubview(listPicImg!)
        addSubview(listName!)
        addSubview(rightDesc!)
        addSubview(rightPic!)
        
        let divideLine = UIView()
        divideLine.backgroundColor = LDLineColorLightGray
        addSubview(divideLine)
        
        divideLine.snp_makeConstraints { (make) in
            
            make.top.equalTo(self.snp_bottom).offset(-0.4)
            make.left.equalTo(self)
            make.right.equalTo(self)
            make.height.equalTo(0.5)
            
        }
    }
    func setupFrame() {
        
        listPicImg?.snp_makeConstraints(closure: { (make) in
            make.top.left.equalTo(margin)
            make.width.height.equalTo(22)
        
        })
        
        listName?.snp_makeConstraints(closure: { (make) in
    
            make.top.bottom.equalTo(listPicImg!)
            make.left.equalTo(listPicImg!.snp_right).offset(Margin_V*2)
            make.width.equalTo(200)
        })
        
        rightPic?.snp_makeConstraints(closure: { (make) in
            
            make.centerY.equalTo(listPicImg!)
            make.right.equalTo(-margin)
            make.width.equalTo(10)
            make.height.equalTo(13)
            
        })
        
        rightDesc?.snp_makeConstraints(closure: { (make) in
            
            make.centerY.equalTo(listPicImg!)
            make.right.equalTo((rightPic?.snp_left)!).offset(-LDMargin_V)

        })
        
    }
}
class meListCellModel: NSObject {
    
    var listPicName:String?
    var listName:String?
    var rightDesc:String?
    
}
